package demo;

/**
 * Created by Administrator on 2018/5/30.
 */
public class TransCode {

    public char[]   getCode(String date,String message){
        //输出的二维数组
        char[] location= new char[3];
        //将message转换成char[]
        char[] msg = message.toCharArray();
        //转换后的二维数组
        char[][] newLetters = new char[3][9];
        //得到月份m,日期数d
        int m = Integer.parseInt(date.substring(0,1));
        int d = Integer.parseInt(date.substring(2,3));
        //初始化二维数组
        char[][] letters = new char[][]{{'A','B','C','D','E','F','G','H','I'},
                {'J','K','L','M','N','O','P','Q','R'},
                {'S','T','U','V','W','X','Y','Z','*'}};
        //根据日期左移分组(m-1)   组内字母左移(d-1)
        //遍历原二维数组，放入到新的数组当中
         for (int i = 0 ; i< 3; i++){
            for(int j  = 0; j < 9; i ++ ){
                newLetters[move(i,(m-1),3)][move(j,(d-1),9)] =  letters[i][j];
        }
    }
        //遍历新二维数组，找到新位置后放入输出数组
        for (int i=0 ; i <3;i++){
        for(int j = 0 ; j <9 ; j++){
           //TODO
        }
        }
        return location;
  }
        /*第num位左移n位*/
        private int move(int num,int n,int length){
            if (num-n>0)
                return num -n;
            else{
               int x=  Math.abs(num-n)%length;
                return length-x;
            }
        }

}
